<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, library-scalable=no" />
  <title>${siteName!""}|书屋管理-添加书屋</title>
  <#include "../common/header.ftl"/>

</head>

<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <aside class="lyear-layout-sidebar">

      <div class="lyear-layout-sidebar-scroll">
        <#include "../common/left-menu.ftl"/>
      </div>

    </aside>
    <!--End 左侧导航-->

    <#include "../common/header-menu.ftl"/>

    <!--页面主要内容-->
    <main class="lyear-layout-content">

      <div class="container-fluid">

        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-header"><h4>添加书屋</h4></div>
              <div class="card-body">
                <form action="add" id="library-add-form" method="post" class="row">
                  <div class="input-group m-b-10">
                    <span class="input-group-addon">书屋名称</span>
                    <input type="text" class="form-control required" id="libraryName" name="libraryName" value="" placeholder="请输入书屋名" tips="请填写书屋名" />
                  </div>
                  <div class="input-group m-b-10">
                    <span class="input-group-addon">书屋楼层</span>
                    <input type="text" class="form-control required" id="libraryFloor" name="libraryFloor" value="" placeholder="请输入书屋楼层" tips="请填写书屋楼层" />
                  </div>
                  <div class="input-group m-b-10">
                    <span class="input-group-addon">所属学院</span>
                    <select name="faculties.id" class="form-control" id="faculties">
                       <#list faculties as facultie>
                        <option value="${facultie.id}">${facultie.name}</option>
                        </#list>
                    </select>
                  </div>
                  <div class="input-group m-b-10">
                    <span class="input-group-addon">管理员名称</span>
                    <input type="text" class="form-control" id="libraryAdmin" name="libraryAdmin" value="" />
                  </div>
                  <div class="input-group m-b-10">
                    <span class="input-group-addon">管理员联系电话</span>
                    <input type="text" class="form-control" id="adminPhone" name="adminPhone" value="" />
                  </div>
                  <div class="input-group" style="margin-top:15px;margin-bottom:15px;padding-left:25px;">
                    书屋状态：
                    <label class="lyear-radio radio-inline radio-primary" style="margin-left:30px;">
                      <input type="radio" name="libraryStatus" value="1" checked="">
                      <span>开放中</span></label>
                    <label class="lyear-radio radio-inline radio-primary">
                      <input type="radio" name="libraryStatus" value="0">
                      <span>关闭中</span>
                    </label>
                  </div>
                  <div class="form-group col-md-12">
                    <button type="button" class="btn btn-primary ajax-post" id="add-form-submit-btn">确 定</button>
                    <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
                  </div>
                </form>

              </div>
            </div>
          </div>

        </div>

      </div>

    </main>
    <!--End 页面主要内容-->
  </div>
</div>
<#include "../common/footer.ftl"/>
<script type="text/javascript" src="/admin/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/admin/js/main.min.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    //提交按钮监听事件
    $("#add-form-submit-btn").click(function(){
      if(!checkForm("library-add-form")){
        return;
      }
      var data = $("#library-add-form").serialize();
      $.ajax({
        url:'add',
        type:'POST',
        data:data,
        dataType:'json',
        success:function(data){
          if(data.code == 0){
            showSuccessMsg('书屋添加成功!',function(){
              window.location.href = 'list';
            })
          }else{
            showErrorMsg(data.msg);
          }
        },
        error:function(data){
          alert('网络错误!');
        }
      });
    });
    //监听上传图片按钮
    $("#add-pic-btn").click(function(){
      $("#select-file").click();
    });
  });

</script>
</body>
</html>
